// Replication code for "Misdemeanor Disenfranchisement?"
// October 2018
// See the readme file for more details on what goes where in this replication package
// Contact Ariel White with questions: arwhi@mit.edu

clear
cd "/nfs/home/A/awhite/shared_space/FLvote/Texas/merging"
set more off
insheet using "voterout_limltest_june15.csv"

regress jail fyear crtjailavg1
ivreg2 vote2012 fyear (jail = crtjailavg1) //Just run 2SLS as in R-- v. similar results

ivreg2 vote2012 fyear (jail = fyear_judge_pred)
//fyear_judge_pred is a leave-one-out judge mean

ivreg2 vote2012 fyear (jail = crtjailavg1), liml 
ivreg2 vote2012 fyear (jail = crtjailavg1), fuller(1)
ivreg2 vote2012 fyear (jail = crtjailavg1), fuller(4)
//these robust estimators all look really similar.

// look at black defendants only
insheet using "voteroutb_limltest_june15.csv", clear

gen male = 0
replace male = 1 if def_sex=="M"

gen classA =0
replace classA=1 if mostsevcharge=="5"

destring ageatfile, gen(filingage) force

ivreg2 vote2012 fyear (jail = crtjailavg1)
ivreg2 vote2012 fyear (jail = crtjailavg1u) //instrument constructed only in this sample

ivreg2 vote2012 fyear (jail = crtjailavg1), liml  
ivreg2 vote2012 fyear (jail = crtjailavg1), fuller(1)
ivreg2 vote2012 fyear (jail = crtjailavg1), fuller(4)

eststo clear
eststo: ivreg2 vote2012 fyear (jail = crtjailavg1u)  
eststo: ivreg2 vote2012 fyear (jail = crtjailavg1u), liml  
ivreg2 vote2012 fyear (jail = crtjailavg1u), fuller(1) 
eststo: ivreg2 vote2012 fyear (jail = crtjailavg1u), fuller(4)
esttab using limlout.tex, tex replace

ivreg2 vote2012 fyear (jail = fyear_judge_pred)
ivreg2 vote2012 fyear male classA (jail = fyear_judge_pred)

ivreg2 vote2012 fyear (jail = fyear_judge_pred), liml  
ivreg2 vote2012 fyear (jail = fyear_judge_pred), fuller(1) 
ivreg2 vote2012 fyear (jail = fyear_judge_pred), fuller(4)

/*
eststo: ivreg2 vote2012 fyear (jail = fyear_judge_pred)

//drop weird age people
drop if filingage < 6570 //under 18.
drop if filingage > 21900 //over 60.


eststo: ivreg2 vote2012 fyear (jail = fyear_judge_pred)
eststo: ivreg2 vote2012 fyear male classA (jail = fyear_judge_pred)
esttab
*/
